#include <QCoreApplication>
#include <QDebug>
#include <QThread>
#include "mythread.h"
 
int main(int argc, char** argv) {
    QCoreApplication app(argc, argv);
    qDebug() << "主线程对象:" << QThread::currentThread();
 
    auto thread = new MyThread;
    qDebug() << "新线程对象:" << thread;
 
    qDebug() << "直接调用任务函数执行任务:";
    thread->doWork();
 
    qDebug() << "QThread::run函数执行任务";
    thread->start(); //线程启动后会自动在新线程中调用run函数
     
    return app.exec();
}
